<?php

/*
 *Task 2103 Usaepay payment interface 
 *Made by Hossam Fawzallah Fares
 *On 17/8/2010 
 */
class usaepayErrorHandlee{
    
    
    private static $errorArray = Array(
                    '5'=>'Error in verification module [module]. Please contact support.',
                    '6'=>'Merchant not found.',
                    '7'=>'Merchant has been deactivated.',
                    '8'=>'Unable to retrieve current batch.',
                    '9'=>'Unable To Create Transaction.  Please Contact Support.',
                    '10'=>'Unable To Allocate Transaction Slot. Please contact support.',
                    '11'=>'Invalid Card Number',
                    '12'=>'Card Number was not between 13 and 16 digits',
                    '13'=>'Invalid Card Number',
                    '14'=>'Invalid Credit Card Number',
                    '15'=>'Invalid expiration date. Must be in MMYY format.',
                    '16'=>'Invalid expiration date. Must be in MMYY format.',
                    '17'=>'Credit card has expired.',
                    '18'=>'Gateway temporarily offline.  Please try again shortly.',
                    '19'=>'Gateway temporarily offline for maintenance. Please try again in a few minutes.',
                    '20'=>'User not configured correctly\',=> please contact support.',
                    '21'=>'Invalid username.',
                    '22'=>'You do not have access to this page.',
                    '23'=>'Specified source key not found.',
                    '24'=>'Transaction already voided.',
                    '25'=>'Unable to find transaction in batch.',
                    '26'=>'The batch has already been closed.  Please apply a credit instead.',
                    '27'=>'Gateway temporarily offline.  Please try again shortly.',
                    '28'=>'Unable to verify source',
                    '29'=>'Unable to generate security key.',
                    '30'=>'Source has been blocked from processing transactions.',
                    '31'=>'Duplicate transaction\',=> wait atleast [minutes] minutes before trying again.',
                    '32'=>'The maximum order amount is $[amount].',
                    '33'=>'The minimum order amount is $[amount].',
                    '34'=>'Your billing information does not match your credit card. Please check with your bank.',
                    '35'=>'Unable to locate transaction',
                    '36'=>'Gateway temporarily offline for maintenance. Please try again in a few minutes.',
                    '37'=>'Customer Name not submitted.',
                    '38'=>'Invalid Routing Number.',
                    '39'=>'Invalid Checking Account Number.',
                    '40'=>'Merchant does not currently support check transactions.',
                    '41'=>'Check processing temporarily offline. Please try again shortly.',
                    '42'=>'Temporarily unable to process transaction. Please try again shortly.',
                    '43'=>'Transaction Requires Voice Authentication. Please Call-In.',
                    '44'=>'Merchant not configured properly (CardAuth)',
                    '45'=>'Auth service unavailable.',
                    '46'=>'Auth service unavailable.',
                    '50'=>'Invalid SSN.',
                    '70'=>'Transaction exceeds maximum amount.',
                    '71'=>'Transaction out of balance.',
                    '80'=>'Transaction type not allowed from this source.',
                    '81'=>'Unable to apply changes\',=> please retry.',
                    '82'=>'Check transactions can not be voided.',
                    '83'=>'Transaction not approved',
                    '84'=>'Pin code required for credit/void',
                    '85'=>'Invalid expiration date. Must be in MMYY format. (3)',
                    '91'=>'Card not accepted by merchant\',=> please try a different card',
                    '101'=>'The batch is in the process of closing.',
                    '102'=>'Transaction is not currently voided.',
                    '103'=>'Transaction has already been settled.',
                    '104'=>'Transaction not a full sale in the current batch',
                    '105'=>'Override not available for requested transaction.',
                    '106'=>'Unable to create customer from requested transaction',
                    '107'=>'Transaction type not supported',
                    '108'=>'Valid AuthCode required for PostAuth',
                    '109'=>'Transaction not supported (debit)',
                    '110'=>'Invalid pin block',
                    '111'=>'Missing track data',
                    '400'=>'Secure Vault Payments are not available',
                    '401'=>'Selected bank is not available',
                    '402'=>'Unable to retreive list of banks.',
                    '451'=>'Error communication with SVP processor',
                    '452'=>'Unable to locate transaction',
                    '453'=>'Incorrect transaction type',
                    '501'=>'Ach transaction type [type] not allowed',
                    '502'=>'Received error from check processor',
                    '503'=>'Unable to pull tracking code. Transaction is not voidable.',
                    '504'=>'Transaction is not voidable.',
                    '505'=>'Transaction has already been voided.',
                    '506'=>'Check processing not setup correctly',
                    '507'=>'User not authorized',
                    '508'=>'Invalid Ach transaction type [type]',
                    '509'=>'Invalid routing number',
                    '510'=>'Insufficent Funds (RPS)',
                    '511'=>'Duplicate Check (RPS)',
                    '512'=>'Declined - Stop Payment (RPS)',
                    '513'=>'Account Closed (RPS)',
                    '514'=>'Stolen/Forged Checks (RPS)',
                    '515'=>'Transaction Declined (RPS)',
                    '2034'=>'Your billing address does not match your credit card. Please check with your bank.',
                    '10001'=>'Processing Error Please Try Again',
                    '10003'=>'Merchant does not accept this type of card (1)',
                    '10004'=>'Merchant does not accept this type of card (2)',
                    '10005'=>'Invalid Card Expiration Date',
                    '10006'=>'Merchant does not accept this type of card (3)',
                    '10007'=>'Invalid amount',
                    '10008'=>'Processing Error Please Try Again  (08)',
                    '10009'=>'Processing Error Please Try Again  (09)',
                    '10010'=>'Processing Error Please Try Again  (10)',
                    '10011'=>'Processing Error Please Try Again  (11)',
                    '10012'=>'Processing Error Please Try Again  (12)',
                    '10013'=>'Processing Error Please Try Again  (13)',
                    '10014'=>'Processing Error Please Try Again  (14)',
                    '10015'=>'Processing Error Please Try Again  (15)',
                    '10016'=>'Processing Error Please Try Again  (16)',
                    '10017'=>'Invalid Invoice Number (17)',
                    '10018'=>'Invalid Transaction Date or Time  (18)',
                    '10019'=>'Processing Error Please Try Again  (19)',
                    '10020'=>'Processing Error Please Try Again  (f20)',
                    '10026'=>'Merchant has been deactivated (26)',
                    '10027'=>'Invalid Merchant Account  (27)',
                    '10030'=>'Processing Error Please Try Again  (30)',
                    '10031'=>'Processing Error Please Retry Transaction  (31)',
                    '10033'=>'Processing Error Please Try Again  (33)',
                    '10043'=>'Sequence Error\',=> Please Contact Support  (43)',
                    '10051'=>'Merchant has been deactivated  (51)',
                    '10054'=>'Merchant has not been setup correctly  (54)',
                    '10057'=>'Merchant does not support this card type (57)',
                    '10059'=>'Processing Error Please Try Again  (59)',
                    '10060'=>'Invalid Account Number  (60)',
                    '10061'=>'Processing Error Please Try Again  (61)',
                    '10062'=>'Processing Error Please Try Again  (62)',
                    '10080'=>'Processing Error Please Try Again  (80)',
                    '10098'=>'Processing Error Please Try Again  (98)',
                    '10099'=>'Session timed out.  Please re-login.',
                    '10100'=>'Your username has been locked for excessive login attempts.',
                    '10101'=>'Your username has been de-activated due to inactivity for 90 days. Please contact support to re-activate your username.',
                    '10102'=>'Unable to open certificate.',
                    '10103'=>'Unable to read certificate.',
                    '10104'=>'Error reading certificate.',
                    '10105'=>'Unable to find original transaction.',
                    '10106'=>'You have tried too many card numbers\',=> please contact merchant.',
                    '10107'=>'Invalid billing zipcode.',
                    '10108'=>'Invalid shipping zipcode.',
                    '10109'=>'Billing state does not match billing zipcode.',
                    '10110'=>'Billing city does not match billing zipcode.',
                    '10111'=>'Billing area code does not match billing zipcode.',
                    '10112'=>'Shipping state does not match shipping zipcode.',
                    '10113'=>'Shipping city does not match shipping zipcode.',
                    '10114'=>'Shipping area code does not match shipping zipcode.',
                    '10115'=>'Merchant does not accept transactions from [country].',
                    '10116'=>'Unable to verify card ID number.',
                    '10117'=>'Transaction authentication required.',
                    '10118'=>'Transaction authentication failed',
                    '10119'=>'Unable to parse mag stripe data.',
                    '10120'=>'Unable to locate valid installation.  Please contact support.',
                    '10121'=>'Wireless key disabled.  Please contact support.',
                    '10122'=>'Wireless key mismatch.',
                    '10123'=>'Success',
                    '10124'=>'Unsupported transaction type. Only authonly\',=> sales and voids may be captured.',
                    '10125'=>'Original transaction not approved.',
                    '10126'=>'Transactions has already been settled.',
                    '10127'=>'Card Declined',
                    '10128'=>'Processor Error ([response])',
                    '10129'=>'Invalid transaction data.',
                    '10130'=>'Libary Error: CURL support not found',
                    '10131'=>'Libary Error: Unable to initialize CURL',
                    '10132'=>'Error reading from card processing gateway.',
                    '10133'=>'Amount exceeds original transaction amount.',
                    '10134'=>'Original transaction not an approved sale',
                    '10135'=>'Unable to locate merchant',
                    '10136'=>'Original transaction not approved.',
                    '10137'=>'Invalid transaction authorization information',
                    '10138'=>'Unsupported transaction authorization request',
                    '10139'=>'Transaction declined (fp)',
                    '10140'=>'Host blocked due to excessive authentication failures. Contact support.',
                    '10141'=>'Specified currency does not match original transaction currency',
                    '10204'=>'Pickup Card (F04)',
                    '10205'=>'Do not Honor (F05)',
                    '10212'=>'Invalid Transaction (F12)',
                    '10215'=>'Invalid Issuer (F15)',
                    '10225'=>'Unable to locate Record (F25)',
                    '10251'=>'Insufficient funds (F51)',
                    '10255'=>'Invalid Pin (F55)',
                    '10257'=>'Transaction not permitted (F57)',
                    '10262'=>'Restricted Card (F62)',
                    '10265'=>'Excess withdrawal count (F65)',
                    '10275'=>'Allowable number of pin tries exceeded (F75)',
                    '10277'=>'Previous messages data inconsistent (F77)',
                    '10278'=>'No checking account (F78)',
                    '10279'=>'Already reversed by switch (F79)',
                    '10280'=>'Invalid date (F80)',
                    '10282'=>'Incorrect CVV (F82)',
                    '10284'=>'Invalid Authorization life cycle (F84)',
                    '10293'=>'Transaction can not be completed\',=> violation of law (F93)',
                    '10297'=>'Declined for CVV failure (F97)',
                    '19000'=>'Unable to save application.',
                    '19001'=>'The field \'[field]\' is required.',
                    '19002'=>'Requested application not found.',
                    '19003'=>'Requested merchant not found.',
                    '19004'=>'Unable to save merchant. Contact support.',
                    '19005'=>'Requested merchant was deleted and is no longer active.',
                    '19006'=>'Invalid search criteria.',
                    '19010'=>'Invalid [date] date.',
                    '19011'=>'Start date not before end date',
                    '19012'=>'Unable to perform currency conversion: [reason]',
                    '19013'=>'Currency is not supported by merchant',
                    '19014'=>'Email address \'[field]\' not valid',
                    '19015'=>'Email address \'[field]\' not valid',
                    '19016'=>'Requested credit card platform not supported',
                    '19017'=>'Requested credit card industry not supported',
                    '19018'=>'Requested electronic check platform not supported',
                    '19019'=>'Requested check platform not supported',
                    '19020'=>'Billing package not found.',
                    '20001'=>'Specified transactions was not found.',
                    '20002'=>'Invalid Security Token.',   
                    '20003'=>'SSL Certificate Does Not Match Source',
                    '20004'=>'Invalid search parameter.',
                    '20005'=>'Host does not have authorization to use this Source.',
                    '20006'=>'Specified Hash type not supported.',
                    '20007'=>'A pin is required to use this source key.',
                    '20008'=>'Unable to validate request.  Check pin and try again.',
                    '20009'=>'Unable to perform requested action',
                    '20010'=>'Requested functionality requires the use of PIN for security purposes.',
                    '20011'=>'Invalid search field \'0[field]\'',
                    '20012'=>'Batch Upload not found',
                    '20013'=>'Batch Upload already completed',
                    '20014'=>'Unsupported file format.',
                    '20015'=>'Unsupported encoding method.',
                    '20016'=>'File data missing.',
                    '20017'=>'Unable to decode data',
                    '20018'=>'Missing field list',
                    '20019'=>'Unknown command',
                    '20020'=>'Unknown field \'[field]\'',
                    '20021'=>'Line [linenum] incorrecty formatted.',
                    '20022'=>'Duplicate batch detected.',
                    '20023'=>'Another batch is already running.',
                    '20024'=>'Invalid command \',[command]\', on line \'[linenum]\'',
                    '20025'=>'Unabled to save batch upload',
                    '20026'=>'Positive dollar amount required',
                    '20027'=>'Unknown comparison type [type]',
                    '20028'=>'Requested report not found',
                    '20029'=>'Unable able to retrieve requested report',
                    '20030'=>'Requested receipt not found',
                    '20031'=>'Invalid content type',
                    '20032'=>'Invalid receipt target',
                    '20033'=>'Receipt name already used',
                    '20034'=>'Error pulling receipt templates',
                    '30001'=>'Merchant does not accept card type',
                    '30002'=>'Card issuer blocked\'=> please try a different card',
                    '40002'=>'Account configuration error',
                    '40003'=>'Error communicating with processor',
                    '40004'=>'Error communicating with processor',
                    '40006'=>'Processor temporarily unavailable',
                    '40007'=>'Processor temporarily unavailable',
                    '40008'=>'Processor temporarily unavailable',
                    '40009'=>'Unable to load transaction',
                    '40010'=>'Transaction has already been processed.',
                    '40011'=>'Transaction exceeds maximum amount',
                    '40012'=>'Failed to validate merchant id.',
                    '40013'=>'Unable to load merchant.',
                    '40014'=>'Merchant not configured correctly.',
                    '40015'=>'Unable to load batch.',
                    '40016'=>'Unable to load transaction data.',
                    '40017'=>'Invalid transaction amount.',
                    '40018'=>'Error communicating with processor.',
                    '40020'=>'Unable to pull transactions',
                    '40021'=>'Batch is empty',
                    '40022'=>'Error sending transaction detail record',
                    '40023'=>'Batch has already been closed',
                    '40024'=>'Transaction has already been settled',
                    '40025'=>'Transaction has not been previously authorized',
                    '40026'=>'Batch is already in the process of closing',
                    '40027'=>'Unable to find requested batch.',
                    '40028'=>'Error closing batch',
                    '40029'=>'Invalid field name.',
                    '40030'=>'Customer Not Found',
                    '40031'=>'Error saving customer',
                    '40032'=>'Unable to parse date',
                    '40033'=>'Username and/or Password Incorrect',
                    '40034'=>'Invalid merchant',
                    '40035'=>'Only a master account can lookup cardnumbers',
                    '40036'=>'Merchant Industry not supported.',
                    '40201'=>'Incorrect transaction type',
                    '40400'=>'Invalid Billing Amount',
                    '40401'=>'Unable to parse customer update data.',
                    '40402'=>'Unknown field [field]',
                    '40403'=>'Next billing date [date] is in the past',
                    '40404'=>'Unable to parse custom data',
                    '40405'=>'Invalid schedule',
                    '40406'=>'Invalid customer data object',
                    '40407'=>'Invalid payment method object',
                    '40408'=>'Payment details missing',
                    '40409'=>'System temporarily unavailable',
                    '40410'=>'Invalid check format specified',
                    '40411'=>'Payment method is not a check',
                    '40412'=>'Invalid account type specified',
                    '40451'=>'Unable to load customer payment method',
                    '40452'=>'Invalid expiration date',
                    '40453'=>'Unable to locate requested payment method.',
                    '40454'=>'Unable to load payment method.',
                    '40455'=>'Error storing payment method record.',
                    '40456'=>'Error storing payment method record.',
                    '40457'=>'No payment methods available',
                    '40458'=>'Command type not supported by Payment Method',
                    '40459'=>'Payment method not added because verification returned a [response]:[errorcode]:[reason]',
                    '40470'=>'No custom fields defined',
                    '41001'=>'Unable to create product database',
                    '41002'=>'Product Not Found',
                    '41003'=>'Error saving product',
                    '41004'=>'Unknown object',
                    '41005'=>'Failed to delete product',
                    '41006'=>'Product Category Not Found',
                    '41007'=>'Error saving product categry',
                    '41008'=>'Failed to delete product category',
                    '41009'=>'Failed to retrieve product categories',
                    '48000'=>'VPAS auth failed',
                    '50001'=>'Error - Call Issuing Bank (T01)',         
                    '50002'=>'Error - Call Issuing Bank Special Conditions (T02)',
                    '50003'=>'Invalid Terminal ID / Merchant ID (T03)',
                    '50004'=>'Hold Call - Pick up Card (T04)',
                    '50005'=>'Declined Do Not Honor Card (T05)',
                    '50006'=>'Tsys General Error XXXX (T06)',
                    '50007'=>'Hold Call - Pick up Card Special (T07)',
                    '50012'=>'Error - Invalid Transaction (T12)',
                    '50013'=>'Invalid Transaction Amount (T13)',
                    '50014'=>'Error - Invalid Card Number',
                    '50015'=>'No Such Issuer Exists (T15)',
                    '50019'=>'Please Re-try Transaction (T19)',
                    '50021'=>'No Action Taken - Unable to Back Out Transaction (T21)',
                    '50028'=>'No Reply - File is Unavailable (T28)',
                    '50039'=>'No Credit Card Account Found (T39)',
                    '50041'=>'Hold Card - Lost Card (T41)',
                    '50043'=>'Hold Card - Stolen Card (T43)',
                    '50051'=>'Insufficient Funds on Card (T51)',
                    '50052'=>'No Checking Account Found (T52)',
                    '50053'=>'No Savings Account Found (T53)',
                    '50054'=>'Exdpired Card (T54)',
                    '50055'=>'Incorrect PIN (T55)',
                    '50057'=>'Transaction is Not Permitted (T57)',
                    '50058'=>'Transaction is Not Permitted (T58)',
                    '50061'=>'Exceeds Withdrawl Limit (T61)',
                    '50062'=>'Invalid Service Code (T62)',
                    '50063'=>'Security Violation (T63)',
                    '50065'=>'Activity Limit Exceeded (T65)',
                    '50075'=>'PIN Tries Exceeded (T75)',
                    '50076'=>'Unable to Reverse\'=> No Match Found (T76)',
                    '50077'=>'No Action - Invalid Data Sent (T77)',
                    '50078'=>'No Account for Processing (T78)',
                    '50079'=>'Already Reserved (T79)',
                    '50080'=>'Invalid Date (T80)',
                    '50081'=>'Cryptographic Error (T81)',
                    '50082'=>'Error - Cash Back Limit Exceeded (T82)',
                    '50083'=>'Can\'t Verify PIN (T83)',
                    '50085'=>'Card OK - No Reason to decline (T85)',
                    '50086'=>'Can\'t Verify PIN (T86)',
                    '50091'=>'No Reply - Issuer or Switch Unavailable (T91)',
                    '50092'=>'Invalid Routing to Account (T92)',
                    '50093'=>'Violation Cannot Complete (T93)',
                    '50094'=>'Duplicate Trans. Unable to Locate (T94)',
                    '50096'=>'Tsys Processor Down Temporarily\'=> Please Retry (T96)',
                    '50127'=>'Card Declined',
                    '50128'=>'Processor Error ([response])',
                    '56786'=>'Card Type Verification Error (T CV)',
                    '56965'=>'Error - Account Length Error (TEA)',
                    '56966'=>'Error - Digit Check Verification Error (TEB)',
                    '56967'=>'Error - Card ID Format Error (TEC)',
                    '57286'=>'Invalid Merchant Account Configuration (T HV)',
                    '57851'=>'Error - Cash Back Not Allowed (TN3)',
                    '57852'=>'Insufficient Funds on Card (TN4)',
                    '57855'=>'Invalid CVV2 Number (TN7)',
                    '58248'=>'Customer Requested Stop on Recurring (TR0)',
                    '58249'=>'Customer Requested Stop on Recurring (TR1)',
                    '58448'=>'Check is OK but Can\'t Be Converted (TT0)',
                    '58449'=>'Check of OK but Can\'t Be Converted (TT1)',
                    '58450'=>'Invalid Routing Number (TT2)',
                    '58451'=>'Amount Exceeds Customer\'s Balance (TT3)',
                    '58452'=>'Unpaid Items on Customers Account (TT4)',
                    '58453'=>'Duplicate Check Number Detected (TT5)',
                    '58454'=>'MICR Error (TT6)',
                    '58455'=>'Too Many Checks Over Customer or Merchant Limit (TT7)',
                    '59001'=>'Invalid merchant platform settings (TSYS)',
                    '65000'=>'Unable to process transaction',
                    '65165'=>'Cardholder Authentication Missing',
                    '65200'=>'Card Declined',
                    '65201'=>'Transaction Requires Voice Authentication. Please Call-In. (P)',
                    '65202'=>'Card Declined - Hold Card\'=> Call',
                    '65203'=>'Transaction Requires Voice Authentication. Please Call-In. (P2)',
                    '65204'=>'Invalid Account/Card Number. (P204)',
                    '65205'=>'Invalid Expiration Date. (P205)',
                    '65206'=>'Invalid International Control Account number. (P206)',
                    '65207'=>'Invalid American Banking Association number. (P207)',
                    '65208'=>'Invalid Personal ID Number [PIN] Entered. (P208)',
                    '65209'=>'Invalid Bank MID (P209)',
                    '65210'=>'Invalid Term No. / merchant ID not valid. (P210)',
                    '65211'=>'Invalid Dollar Amount (P211)',
                    '65213'=>'Invalid Transaction Format. (P213)',
                    '65214'=>'Please Re-Try or Call In. Unable to Reach Auth. Center. (P214)',
                    '65215'=>'Hold Card - Lost/Stolen Card. (P215)',
                    '65216'=>'Invalid Personal ID (P214)',
                    '65217'=>'Amount Exceeds Card Limit (P217)',
                    '65218'=>'Authorizer Denies Transaction. (P218)',
                    '65220'=>'Call Support. Fatal communications error. (P220)',
                    '65240'=>'Do Not Honor. Card Not on File. (P240)',
                    '65248'=>'CVC2/CID Rejected by Issuer. (P248)',
                    '65308'=>'Invalid Card. MOD 10 Failed. (P308)',
                    '65309'=>'Invalid Terminal ID. (P309)',
                    '65310'=>'Invalid Card Number Length. (P310)',
                    '65311'=>'Invalid Terminal File. (P311)',
                    '65312'=>'Invalid Card Number BIN. (P312)',
                    '65313'=>'Merchant/Store # Not On File. (P313)',
                    '65314'=>'Processor Couldn\'t Read Store File (P314)',
                    '65315'=>'Invalid Trans Code for Card Type. (P315)',
                    '65317'=>'Invalid Card. Discover Not Setup. (P317)',
                    '65318'=>'Invalid Card Length. (P318)',
                    '65319'=>'Invalid Amount. (P319)',
                    '65320'=>'Invalid Format. Missing Field Separator for ETX. (P320)',
                    '65321'=>'Invalid/Missing Auth. Code. (P321)',
                    '65322'=>'Invalid Industry Date. (P322)',
                    '65323'=>'Invalid Transaction Class. Not F. (P323)',
                    '65324'=>'Invalid Market Specific Data Indicator. (P324)',
                    '65325'=>'Invalid Duration. (P325)',
                    '65326'=>'Invalid Preferred Customer Indicator. (P326)',
                    '65327'=>'Invalid Card Type Reversal. (P327)',
                    '65328'=>'Invalid Industry Incremental (P328)',
                    '65329'=>'Invalid Industry Incremental. (P329)',
                    '65330'=>'Invalid Incremental Reversal. (P330)',
                    '65331'=>'Invalid Folio Number. (P331)',
                    '65332'=>'Invalid Charge Descriptor. (P332)',
                    '65333'=>'Invalid Industry/No Show. (P333)',
                    '65334'=>'Invalid Card Type / Market. (P334)',
                    '65335'=>'Invalid Vehicle Number. (P335)',
                    '65336'=>'Invalid Odometer Number. (P336)',
                    '65337'=>'Invalid Drivers Number. (P337)',
                    '65338'=>'Invalid or Missing Order Number (P338)',
                    '65339'=>'Invalid Combination of SIC/MO/TO. (P339)',
                    '65340'=>'Reversal Already Exists. (P340)',
                    '65341'=>'Invalid Reversal Amount. (P341)',
                    '65342'=>'Invalid PIN Cabability. (P342)',
                    '65343'=>'Invalid Authorization Characters. (P343)',
                    '65344'=>'Invalid Transaction ID. Non-digits. (P344)',
                    '65345'=>'Transaction ID Doesn\'t Match Original Auth. (P345)',
                    '65346'=>'Invalid BankNet Ref. Number. (P346)',
                    '65347'=>'Invalid Duration Value (P347)',
                    '65348'=>'Market Specifier Doesn\'t Match CPS Type. (P348)',
                    '65349'=>'Industry Code Doesn\'t Match CPS Type. (P349)',
                    '65350'=>'Invalid Reversal Method (Manual) (P350)',
                    '65353'=>'Invalid SIC for Premier MasterCard. (P343)',
                    '65357'=>'Retail Issued Account Not Valid. (P357)',
                    '65358'=>'American Express Not Supported by Merchant. (P358)',
                    '65359'=>'Diners Capture Not Allowed by Merchant. (P359)',
                    '65360'=>'Carte Blanche Not Allowed by Merchant (P360)',
                    '65361'=>'JCB Not Allowed by Merchant. (P361)',
                    '65362'=>'Invalid Electronic Commerce Data (P362)',
                    '65376'=>'Card Code Data Error (P376)',
                    '65602'=>'Please Re-try or Call In. Auth Center Not Reached. (P602)',
                    '65907'=>'Batch not in balance',
                    '65999'=>'Client Not Setup Properly (P999)',
                    '70001'=>'Currency is required.',
                    '70002'=>'Error communicating with processor.',
                    '70003'=>'Invalid currency code',
                    '70004'=>'Invalid source currency selected',
                    '70005'=>'Invalid destination currency selected',
                    '70006'=>'Unable to pull rate list: [reason]',
                    '70007'=>'Merchant account does not have multi-currency support enabled.',
                    '70008'=>'Postal Code is required',
                    '70009'=>'Postal Code may not exceed 9 characters',
                    '70010'=>'Merchant not configured',         
                    '70011'=>'Merchant not configured',
                    '70012'=>'Merchant not configured',
                    '70013'=>'Unsupported Card Type',
                    '70014'=>'Transaction rejected by processor',
                    '70015'=>'Error reading from processor',
                    '70016'=>'Error communicating with processor',
                    '71005'=>'Declined Do Not Honor Card',
                    '71015'=>'No Such Issuer Exists (PP15)',
                    '71039'=>'No Credit Card Account Found',
                    '71051'=>'Insufficient Funds on Card',
                    '71052'=>'No Checking Account Found',
                    '71053'=>'No Savings Account Found',
                    '71057'=>'Transaction is Not Permitted',
                    '71058'=>'Transaction is Not Permitted',
                    '71061'=>'Exceeds Withdrawl Limit',
                    '71062'=>'Invalid Service Code',
                    '71065'=>'Activity Limit Exceeded',
                    '71075'=>'PIN Tries Exceeded',
                    '71093'=>'Violation Cannot Complete',
                    '71094'=>'Duplicate Trans. Unable to Locate',
                    '77786'=>'Card Type Verification Error',
                    '78852'=>'Insufficient Funds on Card',
                    '78855'=>'Invalid CVV2 Number',
                    '79248'=>'Customer Requested Stop on Recurring',
                    '79249'=>'Customer Requested Stop on Recurring',
                    '79448'=>'Check is OK but Can\'t Be Converted',
                    '79449'=>'Check of OK but Can\'t Be Converted',
                    '79451'=>'Amount Exceeds Customer\'s Balance',
                    '79452'=>'Unpaid Items on Customers Account',
                    '79453'=>'Duplicate Check Number Detected',
                    '89000'=>'Batch Rejected by Global (Unmapped Response)',
                    '89001'=>'Batch not in balance (G0NB)',
                    '89103'=>'Invalid Merchant (G003)',
                    '89112'=>'Invalid Tran Code (G012)',
                    '89113'=>'Invalid Amount (G013)',
                    '89114'=>'Invalid Cardnumber (G014)',
                    '89119'=>'Retry Tramsaction (G019)',
                    '89154'=>'Incorrect Exp Date (G054)',
                    '89155'=>'Invalid Pin (G055)',
                    '89158'=>'Unauthorized Transaction (G058)',
                    '89175'=>'Max Pin Retries',
                    '89194'=>'Duplicate Transaction (G094)',
                    '89201'=>'System Unavailable (G0C1)',
                    '89302'=>'Processor Error (G0N2)',
                    '89303'=>'Processor Error (G0N3)',
                    '89304'=>'Processor Error (G0N4)',
                    '89305'=>'Processor Error (G0N5)',
                    '89306'=>'Processor Error (G0N6)',
                    '89307'=>'Processor Error (G0N7)',
                    '89308'=>'Invalid Data (G0N8)',
                    '89310'=>'No Trans Found (G0NA)',
                    '89402'=>'DB Unavailable (G0P2)',
                    '89405'=>'Unauth User (G0P5)',
                    '89406'=>'Invalid Card (G0P6)',
                    '89501'=>'EDC Unavailable (G0T1)',
                    '89502'=>'Processor Error (G0T2)',
                    '89611'=>'Exceeds Max Amount (G121)',
                    '89612'=>'Invalid CID (G122)',
                    '89999'=>'Transaction failed (G)',
                    '90909'=>'The server is temporarily unavailable.  Please use secondary url or retry later.',
                    '900001'=>'Internal Server Error'
            
            );
    //This function get Web service error message and log it in payment.log and show custom message to user
    public static function getError( $error_message)
    {
        //create instance of dispatch 
        $dispatcher=sfContext::getInstance()->getEventDispatcher();
        //split message details and message number
        list($num, $msg)= explode(":",  $error_message)  ;  
        //check if logging enabled
        if (sfConfig::get('sf_logging_enabled'))
	{
         $dispatcher->notify(new sfEvent($num, 'paymentlog.log', array( $msg)));
        }
        
        //array holds all errors number and custom message to be returned
         $errors= self::$errorArray;
         
         /*
          * check if the error code exist if true show the custom message
          * else showunknown error message
          */
         
         if(array_key_exists($num,$errors))
         {
        $message=$errors[$num];
         }
         else
         {
            $message='Unknown error happen' ;
         }
         //return the custom message
        return $message;
    }


    public static function getErrorMessage($pErrorCode){

        $num = $pErrorCode;
        
        $errors= self::$errorArray;

         /*
          * check if the error code exist if true show the custom message
          * else showunknown error message
          */

         if(array_key_exists($num,$errors))
         {
        $message=$errors[$num];
         }
         else
         {
            $message='Unknown error happen' ;
         }
         //return the custom message
        return $message;
    }
}

?>